package nongchang.kuaijiecaifu.com.ncapp_android.ui.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

import nongchang.kuaijiecaifu.com.ncapp_android.util.ScaleUtil;

/**
 * Created by Administrator on 2016/6/16 0016.
 */
public class OvalLine extends View {
    public OvalLine(Context context) {
        super(context);
    }

    public OvalLine(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public OvalLine(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint p = new Paint();
        p.setColor(Color.parseColor("#FFCBCBCB"));
        p.setStrokeWidth(1);
        p.setAntiAlias(true);
        int left= ScaleUtil.dip2px(getContext(),20);
        int right=ScaleUtil.dip2px(getContext(),80);
        int top=ScaleUtil.dip2px(getContext(),15);
        int bottom=ScaleUtil.dip2px(getContext(),30);
        canvas.drawLine(0, top, left, top, p);// 画线
        canvas.drawLine(right, top, ScaleUtil.dip2px(getContext(),getMeasuredWidth()), top, p);// 画线
        p.setStyle(Paint.Style.STROKE);//设置空心
        RectF oval1=new RectF(left,0,right,bottom);
        canvas.drawArc(oval1, 180, 180, false, p);//小弧形
        p.setStyle(Paint.Style.FILL);
        p.setColor(Color.WHITE);
        RectF oval2=new RectF(left+2,2,right-2,bottom-2);
        canvas.drawOval(oval2,p);
    }
}
